package com.hb.trade.server.project.section.service.status;

import com.hb.core.pojo.enums.SectionStatusEnum;
import com.hb.core.pojo.project.section.dto.BidSectionDTO;
import com.hb.trade.server.project.calibration.service.BidWinResultService;
import com.hb.trade.server.project.deal.service.BidCandidateService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Service;

/**
 * 中标公示已发布判断逻辑
 *
 * @author zhaojk
 */
@Setter
@Getter
@Service
public class WinBidNoticeDeployed implements CalSectionStatus {
    /**
     * 当前逻辑的标段状态
     */
    private final static SectionStatusEnum SECTION_STATUS = SectionStatusEnum.WIN_BID_NOTICE_DEPLOYED;

    /**
     * 排序号
     */
    private Integer sortCode = SECTION_STATUS.getCode();

    private final BidWinResultService bidWinResultService;

    public WinBidNoticeDeployed(BidWinResultService bidWinResultService) {
        this.bidWinResultService = bidWinResultService;
    }

    @Override
    public Long getSectionStatus(BidSectionDTO section) {
        // 查询中标结果公示是否已发布
        boolean releaseFlag = bidWinResultService.releaseFlagBySectionId(section.getId());
        if (releaseFlag){
            return SectionStatusEnum.WIN_BID_NOTICE_DEPLOYED.getId();
        }
        return null;
    }

    @Override
    public Integer getSort() {
        return sortCode;
    }
}
